//
//  CSBOwenSweeping.swift
//  CurSodoboAer
//
//  Created by CurSodoboAer on 2024/11/5.
//

import UIKit

class CSBOwenSweeping: CSBComeenrSweeping {
    
    private let minHeadrBigimagCSB = UIImageView.init()
    
    private let comeAICSBACti = UIButton.init()
    let infocorieBg = UIView()
    
    let coinMineLblCSB = UILabel.init()
    
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        infocorieBg.layer.cornerRadius = 75.xQQ
        infocorieBg.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMaxXMaxYCorner]
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        fokkerButton.userINfoCSBF = ("\(CSBFetcherAll.Hammer.folooweNewstCSB.count)","Followers")
        mineNameCSB.text = CSBFetcherAll.Hammer.melingCSBINfo["csbpersonName"]
        likemeButton.userINfoCSBF = ("\(CSBFetcherAll.Hammer.likemeuCSB.count)","Following")
        coinMineLblCSB.text = CSBFetcherAll.Hammer.melingCSBINfo["allCoind"]
        minHeadrBigimagCSB.image = CSBFetcherAll.Hammer.shoHeadCSB
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor(red: 0.64, green: 0.41, blue: 0.98, alpha: 1)
        minHeadrBigimagCSB.layer.cornerRadius =  205.xQQ
        minHeadrBigimagCSB.layer.masksToBounds = true
        minHeadrBigimagCSB.contentMode = .scaleAspectFill
        minHeadrBigimagCSB.backgroundColor = .lightGray
        comeAICSBACti.setBackgroundImage(UIImage.init(named: "csb_AI"), for: .normal)
        comeAICSBACti.addTarget(self, action: #selector(normalPickAISegmengt), for: .touchUpInside)
        infocorieBg.backgroundColor = UIColor(red: 0.75, green: 0.99, blue: 0.01, alpha: 1)
        
        
        
        
        addAotherCSB()
        
        addINfoOtherCSBView()
    }
    
    private  func addAotherCSB()  {
        
        let scrope = UIScrollView.init()
        scrope.backgroundColor = .clear
        
        view.addSubview(minHeadrBigimagCSB)
        minHeadrBigimagCSB.snp.makeConstraints { make in
            make.width.height.equalTo(410.xQQ)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(11.xQQ)
        }
        
        view.addSubview(comeAICSBACti)
        let stattusBarHeight = UIApplication.shared.statusBarFrame.height
        comeAICSBACti.snp.makeConstraints { make in
            make.width.height.equalTo(44.xQQ)
            make.trailing.equalToSuperview().inset(12)
            make.top.equalToSuperview().offset(stattusBarHeight + 16)
        }
        view.addSubview(scrope)
        scrope.snp.makeConstraints { make in
            make.leading.trailing.bottom.equalToSuperview()
            make.top.equalToSuperview().offset(270.xQQ)
        }
        scrope.addSubview(infocorieBg)
        infocorieBg.snp.makeConstraints { make in
            make.leading.equalToSuperview()
            make.width.equalTo(331.xQQ)
            make.height.equalTo(149)
            make.top.equalToSuperview()
            make.trailing.equalToSuperview().offset(-UIScreen.main.bounds.width + 331.xQQ)
        }
        
        
        let itemfir = (UIScreen.main.bounds.width - 36.xQQ)/2
        
        let cominkCSB = UIImageView.init(image: UIImage.init(named: "csb_coinBg"))
        let blacklistCSB = UIView()
        let eidtCSB = UIView()
        let setingkCSB = UIView()
        
        
        scrope.addSubview(cominkCSB)
        scrope.addSubview(blacklistCSB)
        scrope.addSubview(eidtCSB)
        scrope.addSubview(setingkCSB)
        
        
        cominkCSB.snp.makeConstraints { make in
            make.width.equalTo(itemfir)
            make.leading.equalToSuperview().inset(12.xQQ)
            make.height.equalTo(120)
            make.top.equalTo(infocorieBg.snp.bottom).offset(20)
        }
        blacklistCSB.snp.makeConstraints { make in
            make.width.equalTo(itemfir)
            make.trailing.equalToSuperview().inset(12.xQQ)
            make.height.equalTo(120)
            make.top.equalTo(infocorieBg.snp.bottom).offset(20)
        }
        
        
        eidtCSB.snp.makeConstraints { make in
            make.width.equalTo(itemfir)
            make.leading.equalToSuperview().inset(12.xQQ)
            make.height.equalTo(120)
            make.top.equalTo(cominkCSB.snp.bottom).offset(12)
        }
        
        setingkCSB.snp.makeConstraints { make in
            make.width.equalTo(itemfir)
            make.trailing.equalToSuperview().inset(12.xQQ)
            make.height.equalTo(120)
            make.top.equalTo(cominkCSB.snp.bottom).offset(12)
            make.bottom.equalToSuperview().offset(-120)
        }
        
      
        
        cominkCSB.isUserInteractionEnabled = true
        cominkCSB.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(semgmengItemAISegmengt(tapgVir:))))
        cominkCSB.tag = 450
        
        blacklistCSB.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        blacklistCSB.layer.cornerRadius = 24
        blacklistCSB.layer.masksToBounds = true
        blacklistCSB.tag = 451
        
        eidtCSB.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        eidtCSB.layer.cornerRadius = 24
        eidtCSB.layer.masksToBounds = true
        eidtCSB.tag = 452
        
        setingkCSB.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        setingkCSB.layer.cornerRadius = 24
        setingkCSB.layer.masksToBounds = true
        setingkCSB.tag = 453
        
        setingkCSB.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(semgmengItemAISegmengt(tapgVir:))))
        eidtCSB.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(semgmengItemAISegmengt(tapgVir:))))
        blacklistCSB.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(semgmengItemAISegmengt(tapgVir:))))
        
        
        coinMineLblCSB.textColor = .white
        coinMineLblCSB.font = UIFont(name: "Futura Bold", size: 24)
        
        let balgjText = UILabel.init()
        balgjText.text = "Wallet Banlance"
        balgjText.textColor = .white
        balgjText.font = UIFont(name: "Helvetica", size: 14)
        
        let nextText = UILabel.init()
        nextText.text = ">"
        nextText.textColor = .white
        nextText.font = UIFont(name: "Helvetica", size: 17)
        nextText.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        nextText.layer.cornerRadius = 14
        nextText.layer.masksToBounds = true
        nextText.textAlignment = .center
        
        
        cominkCSB.addSubview(coinMineLblCSB)
        cominkCSB.addSubview(balgjText)
        cominkCSB.addSubview(nextText)
        coinMineLblCSB.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(16.xQQ)
            make.top.equalToSuperview().offset(12.xQQ)
        }
        balgjText.snp.makeConstraints { make in
            make.leading.equalTo(coinMineLblCSB)
            make.top.equalTo(coinMineLblCSB.snp.bottom).offset(3)
        }
        
        nextText.snp.makeConstraints { make in
            make.width.equalTo(46)
            make.height.equalTo(28)
            make.top.equalTo(balgjText.snp.bottom).offset(12.xQQ)
            make.leading.equalTo(balgjText)
        }
        
        
    
        let blckimgcsb = UIImageView.init(image: UIImage.init(named: "me_blick"))
        let editimgcsb = UIImageView.init(image: UIImage.init(named: "me_sEdit"))
        let setingimgcsb = UIImageView.init(image: UIImage.init(named: "me_site"))
        
        
        let nextblckimgcsb = UIImageView.init(image: UIImage.init(named: "arrow_me_righWhite"))
        let nexteditimgcsb = UIImageView.init(image: UIImage.init(named: "arrow_me_righWhite"))
        let nextsetingimgcsb = UIImageView.init(image: UIImage.init(named: "arrow_me_righWhite"))
        
        
        let blckjText = UILabel.init()
        blckjText.text = "Blocklist"
        blckjText.textColor = .white
        blckjText.font = UIFont(name: "Helvetica", size: 16)
        
        let edijText = UILabel.init()
        edijText.text = "Edit Profile"
        edijText.textColor = .white
        edijText.font = UIFont(name: "Helvetica", size: 16)
        
        let sitejText = UILabel.init()
        sitejText.text = "Settings"
        sitejText.textColor = .white
        sitejText.font = UIFont(name: "Helvetica", size: 16)
        
        blacklistCSB.addSubview(blckimgcsb)
        
        blacklistCSB.addSubview(blckjText)
        blacklistCSB.addSubview(nextblckimgcsb)
        blckimgcsb.snp.makeConstraints { make in
            make.width.height.equalTo(40.xQQ)
            make.top.left.equalToSuperview().offset(15.xQQ)
        }
        
        blckjText.snp.makeConstraints { make in
            make.leading.equalTo(blckimgcsb)
            make.top.equalTo(blckimgcsb.snp.bottom).offset(15)
        }
        
        nextblckimgcsb.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-10)
            make.width.height.equalTo(10)
            make.centerY.equalTo(blckjText)
        }
        
        
        eidtCSB.addSubview(editimgcsb)
        
        eidtCSB.addSubview(edijText)
        eidtCSB.addSubview(nexteditimgcsb)
        
        editimgcsb.snp.makeConstraints { make in
            make.width.height.equalTo(40.xQQ)
            make.top.left.equalToSuperview().offset(15.xQQ)
        }
        
        edijText.snp.makeConstraints { make in
            make.leading.equalTo(editimgcsb)
            make.top.equalTo(editimgcsb.snp.bottom).offset(15)
        }
        
        nexteditimgcsb.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-10)
            make.width.height.equalTo(10)
            make.centerY.equalTo(edijText)
        }
        
        
        
        
        setingkCSB.addSubview(setingimgcsb)
        setingkCSB.addSubview(sitejText)
        setingkCSB.addSubview(nextsetingimgcsb)
        
        setingimgcsb.snp.makeConstraints { make in
            make.width.height.equalTo(40.xQQ)
            make.top.left.equalToSuperview().offset(15.xQQ)
        }
        
        sitejText.snp.makeConstraints { make in
            make.leading.equalTo(setingimgcsb)
            make.top.equalTo(setingimgcsb.snp.bottom).offset(15)
        }
        
        nextsetingimgcsb.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-10)
            make.width.height.equalTo(10)
            make.centerY.equalTo(sitejText)
        }
        
        
    }
    
    
    let mineNameCSB = UILabel.init()
    let fokkerButton = CSBMeUserlistVutton.init()
    let likemeButton = CSBMeUserlistVutton.init()
    
    func addINfoOtherCSBView()  {
        
        
        mineNameCSB.font =   UIFont(name: "Futura Medium", size: 26)
        mineNameCSB.textColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        
        let uideCSB = UILabel.init()
        uideCSB.text = "UID: " + (CSBFetcherAll.Hammer.melingCSBINfo["csbpersonID"] ?? "")
        uideCSB.font =   UIFont(name: "Helvetica", size: 15)
        uideCSB.textColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha:0.5)
        
        
        
        
        fokkerButton.addTarget(self, action: #selector(kUngkung(bujg:)), for: .touchUpInside)
        fokkerButton.tag = 99
        
        
        
        likemeButton.addTarget(self, action: #selector(kUngkung(bujg:)), for: .touchUpInside)
        likemeButton.tag = 100
        
        
        let momentButton = CSBMeUserlistVutton.init()
        let monnentCOunt = ((CSBFetcherAll.Hammer.melingCSBINfo["csbEmail"] == "Qin1234@gmail.com") && ((UserDefaults.standard.object(forKey: "testuseraccountDel") as? Bool ?? false) == false)) ? "1" : "0"
        
        momentButton.userINfoCSBF = ( monnentCOunt,"Moments")
        momentButton.addTarget(self, action: #selector(kUngkung(bujg:)), for: .touchUpInside)
        momentButton.tag = 101
        
        infocorieBg.addSubview(mineNameCSB)
        infocorieBg.addSubview(uideCSB)
        infocorieBg.addSubview(fokkerButton)
        infocorieBg.addSubview(likemeButton)
        
        infocorieBg.addSubview(momentButton)
        
        mineNameCSB.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(14.xQQ)
            make.leading.equalToSuperview().offset(20.xQQ)
            make.width.lessThanOrEqualTo(100)
        }
        uideCSB.snp.makeConstraints { make in
            make.leading.equalTo(mineNameCSB.snp.trailing).offset(20)
            make.centerY.equalTo(mineNameCSB)
        }
        let suhrf = (331.xQQ - 60.xQQ)/3
        
        fokkerButton.snp.makeConstraints { make in
            make.width.equalTo(suhrf)
            make.height.equalTo(60)
            make.leading.equalToSuperview().offset(15.xQQ)
            make.bottom.equalToSuperview().offset(-20)
        }
        
        likemeButton.snp.makeConstraints { make in
            make.width.equalTo(suhrf)
            make.height.equalTo(60)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-20)
        }
        
        momentButton.snp.makeConstraints { make in
            make.width.equalTo(suhrf)
            make.height.equalTo(60)
            make.trailing.equalToSuperview().offset(-15.xQQ)
            make.bottom.equalToSuperview().offset(-20)
        }
        
    }
    @objc func semgmengItemAISegmengt(tapgVir:UITapGestureRecognizer) {
        
        var csbBayui = [Int]()
        let csbNUmber = Array(repeating: 10, count: 64)
        let csbNumbe2 = Array(repeating: 96, count: 50)
        var cabSunmAll: Int = 0

        csbBayui.append(11)
        cabSunmAll = csbNUmber.count
        if cabSunmAll > 5 {
            csbBayui.append(contentsOf: csbNUmber)
        }else{
            csbBayui.append(contentsOf: csbNumbe2)
        }

        csbBayui.append(contentsOf: [52, 6, 11])
        csbBayui.removeLast()
        cabSunmAll = csbBayui.count

       
        
        if tapgVir.view?.tag == 450  && (cabSunmAll >= 0) && (csbBayui.count >= 0){
            self.navigationController?.pushViewController(CSChoiPayuSweeping.init(), animated: true)
        }
        
 
        if tapgVir.view?.tag == 451 {
            let userrelaitinVC = CSBFAnfUserlistSweeping.init()
            userrelaitinVC.minhCurTitlr = "Blocklist"
            self.navigationController?.pushViewController(userrelaitinVC, animated: true)
        }
        
        
        if tapgVir.view?.tag == 452 {
            
            self.navigationController?.pushViewController(CSBEditSweeping.init(), animated: true)
        }
        
        if tapgVir.view?.tag == 453 {
            self.navigationController?.pushViewController(CSBMInetSetitingSwpping.init(), animated: true)
        }
    }
    
    
   @objc func kUngkung(bujg:CSBMeUserlistVutton)  {
       
       var csbBayui = [Int]()
       let csbNUmber = Array(repeating: 10, count: 64)
       let csbNumbe2 = Array(repeating: 96, count: 50)
       var cabSunmAll: Int = 0

       csbBayui.append(11)
       cabSunmAll = csbNUmber.count
       

       if bujg.tag == 99 {
           let lijg =   CSBFAnfUserlistSweeping.init()
           lijg.minhCurTitlr = "Fans"
           self.navigationController?.pushViewController(lijg, animated: true)
       }
       
       if bujg.tag == 100 {
           let lijg =   CSBFAnfUserlistSweeping.init()
           lijg.minhCurTitlr = "Likes"
           self.navigationController?.pushViewController(lijg, animated: true)
       }
       if cabSunmAll > 5 {
           csbBayui.append(contentsOf: csbNUmber)
       }else{
           csbBayui.append(contentsOf: csbNumbe2)
       }

       csbBayui.append(contentsOf: [52, 6, 11])
       csbBayui.removeLast()
       cabSunmAll = csbBayui.count

     
       if bujg.tag == 101 && (cabSunmAll >= 0) && (csbBayui.count >= 0){
           self.navigationController?.pushViewController(CSBMInetMonmentSwpping.init(), animated: true)
           return
       }
       
       
    }
    
    @objc func normalPickAISegmengt() {
        var csbBayui = [Int]()
        let csbNUmber = Array(repeating: 10, count: 64)
        let csbNumbe2 = Array(repeating: 96, count: 50)
        var cabSunmAll: Int = 0

        csbBayui.append(11)
        cabSunmAll = csbNUmber.count
        if cabSunmAll > 5 {
            csbBayui.append(contentsOf: csbNUmber)
        }else{
            csbBayui.append(contentsOf: csbNumbe2)
        }

        csbBayui.append(contentsOf: [52, 6, 11])
        csbBayui.removeLast()
        cabSunmAll = csbBayui.count

        if (cabSunmAll >= 0) && (csbBayui.count >= 0) {
            self.navigationController?.pushViewController(CSBAISweeping.init(), animated: true)
        }

        
    }
}




class CSBMeUserlistVutton: UIButton {
    private var dymCountCSB = UILabel.init()
    private var bauNameCSB = UILabel.init()
    var userINfoCSBF:(String,String)? {
        didSet{
            
            var csbBayui = [Int]()
            let csbNUmber = Array(repeating: 10, count: 64)
            let csbNumbe2 = Array(repeating: 96, count: 50)
            var cabSunmAll: Int = 0

            csbBayui.append(11)
            cabSunmAll = csbNUmber.count
            if cabSunmAll > 5 {
                csbBayui.append(contentsOf: csbNUmber)
            }else{
                csbBayui.append(contentsOf: csbNumbe2)
            }

            csbBayui.append(contentsOf: [52, 6, 11])
            csbBayui.removeLast()
            cabSunmAll = csbBayui.count

            if (cabSunmAll >= 0) && (csbBayui.count >= 0) {
                dymCountCSB.text = userINfoCSBF?.0
                bauNameCSB.text = userINfoCSBF?.1
            }

           
            
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
        dymCountCSB.textColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
        dymCountCSB.font =   UIFont(name: "Futura Medium", size: 26)
        dymCountCSB.textAlignment = .center
        
        bauNameCSB.textColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 0.5)
        bauNameCSB.font = UIFont(name: "Futura Medium", size: 12)
        bauNameCSB.textAlignment = .center
        addSubview(dymCountCSB)
        dymCountCSB.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(5)
           
        }
        addSubview(bauNameCSB)
        bauNameCSB.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(dymCountCSB.snp.bottom).offset(4.xQQ)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
